package com.kuhyygy.file;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Android读取文件
 * @author acer
 *
 */
public class FileService {
	
	public void save(OutputStream os, String content) throws IOException {
		os.write(content.getBytes());
		os.close();
	}
	
	public String read(InputStream is) throws IOException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		byte[] buff = new byte[1024];
		int len = 0;
		while ((len = is.read(buff)) != -1) {
			baos.write(buff, 0, len);
		}
		byte[] data = baos.toByteArray();
		baos.close();
		is.close();
		return new String(data);
	}

}
